<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>Styling Titpap 样式 - itxst.com</title>
    <meta name="keywords" content="Styling Titpap 样式" />
    <meta name="description" content="Titpap 编辑器由于是 headless 所以它没有提供任何样式，这意味我们可以完全控制 Titap 的样式，我们可以通过作用域内或全局 CSS 来控制样式也可以自定义 class 来定制样式。" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <meta http-equiv="Content-Language" content="zh-CN">
    <link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon" />
    <link href="/css/zt.css?ver=1.6.6" rel="stylesheet" type="text/css" media="all" />
    <script type="text/javascript" language="javascript" src="/js/jquery.js?ver=1.6.6"></script>
    <script type="text/javascript" src="/js/highlight/highlight.min.js?ver=1.6.6"></script>
    <link rel="stylesheet" type="text/css" href="/js/highlight/styles/vs2015x.css?ver=1.6.6">
    <script type="text/javascript" language="javascript" src="/js/comm.js?ver=1.6.6"></script>
    <script type="text/javascript" language="javascript" src="/js/zt.js?ver=1.6.6"></script>
    <script type="text/javascript" charset="utf-8" src="/js/layer/layer.js?ver=1.6.6"></script>
    <link rel="alternate" media="only screen and(max-width: 640px)" href="http://m.itxst.com/tiptap/styling.html" >
    <!--[if lte IE 9]>
    <script src="/js/respond/respond.js?ver=1.6.6"></script>
    <![endif]-->
</head>
<body>
    <div class="body"  >
        <div class="header">
            <div class="naver">
                <div class="logo">
                    <a href="/"><img src="/img/logov31.png" /></a>
                </div>
                <div class="naver-left">
                 <a href="/tiptap/tutorial.html">tiptap 中文文档</a>
                </div>
                <div class="naver-search">
                    <div class="naver-search-txt">
                        <input type="text" id="keyword" placeholder="Please enter the keyword" data-topic="tiptap">
                    </div>
                    <div class="naver-search-btn"><a href="javascript:void(0)" onclick="Search()">Search</a></div>
                </div>
                 <div class="naver-right"> 
                        <a href="/ag-grid/tutorial.html">AG-GRID</a> 
                        <a href="/tiptap/tutorial.html">Tiptap</a> 
                        <a href="/css-flex/tutorial.html">CSS-FLEX</a> 
                        <a href="/Bootstrap-Table/QuickStart.html">Bootstrap-Table</a> 
                </div>
            </div>
            <div class="path">
                
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="pagew">
        <div class="page" >
            <div class="page-body">
                <div class="content-detail">
                    <h1>Styling Titpap 样式</h1>
               
               <p class="p"><strong>Titpap</strong> 编辑器由于是 <strong>headless</strong> 所以它没有提供任何样式，这意味我们可以完全控制 <strong>Titap</strong> 的样式，我们可以通过作用域内或全局 <strong>CSS</strong> 来控制样式也可以自定义 <strong>class</strong> 来定制样式。</p><h2>作用域样式</h2><pre class="brush:css;toolbar:false"><code class="language-css">/* Scoped to the editor */
.ProseMirror p {
  margin: 1em 0;
  color:red
}</code></pre><h2>全局样式</h2><pre class="brush:css;toolbar:false"><code class="language-css">/* Global styling */
p {
  margin: 1em 0;
  color:red
}</code></pre><h2>自定义 class</h2><pre class="brush:js;toolbar:false"><code class="language-javascript">//自定义段落样式
new Editor({
  extensions: [
    Document,
    Paragraph.configure({
      HTMLAttributes: {
        class: 'my-custom-paragraph',
      },
    }),
    Heading.configure({
      HTMLAttributes: {
        class: 'my-custom-heading',
      },
    }),
    Text,
  ],
})</code></pre><p>上面的设置将会渲染成以下代码</p><pre class="brush:html;toolbar:false"><code class="language-html">&lt;h1 class="my-custom-heading"&gt;Example Text&lt;/p&gt;
&lt;p class="my-custom-paragraph"&gt;Wow, that’s really custom.&lt;/p&gt;</code></pre><h2>编辑器样式</h2><pre class="brush:js;toolbar:false"><code class="language-javascript">//编辑器容器将会加上以下样式
new Editor({
  editorProps: {
    attributes: {
      class: 'prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none',
    },
  },
})</code></pre><h2>自定义html</h2><pre class="brush:js;toolbar:false"><code class="language-javascript">//将加粗渲染成b标签或者strong标签
import Bold from '@tiptap/extension-bold'

const CustomBold = Bold.extend({
  renderHTML({ HTMLAttributes }) {
    // Original:
    // return ['strong', HTMLAttributes, 0]
    return ['b', HTMLAttributes, 0]
  },
})

new Editor({
  extensions: [
    // …
    CustomBold,
  ],
})</code></pre><h2>使用Tailwind CSS</h2><pre class="brush:html;toolbar:false"><code class="language-html">&lt;!-- load tailwind --&gt;
&lt;script src="https://cdn.tailwindcss.com?plugins=typography"&gt;&lt;/script&gt;

&lt;!-- provide element --&gt;
&lt;div class="element"&gt;&lt;/div&gt;

&lt;!-- create editor --&gt;
&lt;script type="module"&gt;
import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'

const editor = new Editor({
  element: document.querySelector('.element'),
  extensions: [
    StarterKit,
  ],
  editorProps: {
    attributes: {
      class: 'prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl m-5 focus:outline-none',
    },
  },
  content: `
    &lt;h2&gt;
      Hi there,
    &lt;/h2&gt;
    &lt;p&gt;
      this is a basic &lt;em&gt;basic&lt;/em&gt; example of &lt;strong&gt;tiptap&lt;/strong&gt;. Sure, there are all kind of basic text styles you’d probably expect from a text editor. But wait until you see the lists:
    &lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;
        That’s a bullet list with one …
      &lt;/li&gt;
      &lt;li&gt;
        … or two list items.
      &lt;/li&gt;
    &lt;/ul&gt;
    &lt;p&gt;
      Isn’t that great? And all of that is editable. But wait, there’s more. Let’s try a code block:
    &lt;/p&gt;
&lt;pre&gt;&lt;code class="language-css"&gt;body {
  display: none;
}&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      I know, I know, this is impressive. It’s only the tip of the iceberg though. Give it a try and click a little bit around. Don’t forget to check the other examples too.
    &lt;/p&gt;
    &lt;blockquote&gt;
      Wow, that’s amazing. Good work, boy! 
      &lt;br /&gt;
      — Mom
    &lt;/blockquote&gt;
  `,
})
&lt;/script&gt;</code></pre>
 
               <h2>
    下载教程 Demo
</h2>
<p class="pe">
   本教程<b>Demo</b>的源码点击这里下载，<a href="https://img1.itxst.com/8/c/8c32fcdc12cb8847c62e405be8a73835.zip" target="_blank" textvalue="Tiptap Demo">Tiptap Demo</a>，下载完成后运行<b>npm i</b>初始化依赖包。
</p>
                </div>
                <div class="content-r">   <a href="/tiptap/tutorial.html" target="_self">
                     <img src="https://img1.itxst.com/0/9/09355b3592a0c16799b504a9f2a70303.png" alt="tiptap 中文文档" />
                    </a>                                                <a href="//www.itxst.com/vue-draggable/tutorial.html" target="_blank">
                                <img src="//img1.itxst.com/b/f/bf9af8368dfac84cd703ef54e1e89d14.png" alt="vue.draggable" />
                            </a>
 
                </div>
            </div>
            <div class="home-menu scroll">
                <div class="tree">
      <a data-level="1" class="leve-1   doc-1   " href="/tiptap/tutorial.html" title="tiptap 中文文档">快速入门</a>
      <a data-level="1" class="leve-1    arrow-2" href="/tiptap/configuration.html" title="Guide 向导">Guide 向导</a>
      <a data-level="2" class="leve-2   doc-1   " href="/tiptap/configuration.html" title="Tiptap 编辑器 Configuration 配置">configuration 配置</a>
      <a data-level="2" class="leve-2   doc-1   " href="/tiptap/roseMirrorapi.html" title="ProseMirror  API">prosemirror  api</a>
      <a data-level="2" class="leve-2   doc-1   " href="/tiptap/menus.html" title="tiptap menus 菜单">menus 菜单</a>
      <a data-level="2" class="leve-2   doc-1    doc-2 " href="/tiptap/styling.html" title="Styling Titpap 样式">styling 样式</a>
      <a data-level="2" class="leve-2   doc-1   " href="/tiptap/output.html" title="Titpap Output 输出格式">output 输出格式</a>
      <a data-level="2" class="leve-2   doc-1   " href="/tiptap/collaborative.html" title="tiptap collaborative 实时协作">collaborative 实时协作</a>
      <a data-level="2" class="leve-2   doc-1   " href="/tiptap/customextensions.html" title="tiptap 自定义扩展">extensions 自定义扩展</a>
      <a data-level="1" class="leve-1    arrow-1" href="/tiptap/api.html" title="tiptap api 列表">API 列表</a>
                 </div>
                 <div  class="clearfix"></div>
            </div>
        </div>
        <div class="clearfix"></div>
           <div class="footer">
© 2023 itxst.com All rights reserved.
</div>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?7e15ed96eb8133218e99de8bc1f5cb61";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>
       </div>
    </div> 
</body>
</html>
